package com.itboye.jigongbao.adpapter

import android.content.Context
import com.itboye.jigongbao.R
import com.itboye.jigongbao.adpapter.baseAdapter.MutiplyCommonAdapter
import com.itboye.jigongbao.adpapter.baseAdapter.ViewHolder
import com.itboye.jigongbao.bean.NotifyMessageBean
import com.itboye.jigongbao.utils.ByTimeUtils.timeFormat

/**
 * Created by Administrator on 2017/11/29.
 */
class NotifyMessageAdapter(context: Context, datas: ArrayList<NotifyMessageBean>, vararg layoutId: Int) : MutiplyCommonAdapter<NotifyMessageBean>(context, datas, layoutId[0]) {

    var context: Context? = null

    init {
        this.context = context
    }

    override fun getItemViewType(position: Int): Int {
        return 0
    }

    override fun getItemPosition(position: Int) {
    }

    override fun convert(holder: ViewHolder?, t: NotifyMessageBean, type: Int, position: Int) {

        holder!!.setText(R.id.tv_message, t.content)
        holder!!.setText(R.id.tv_date, timeFormat("yyyy-MM-dd HH:mm:ss", t.create_time * 1000))
        when (t.msg_status) {
            0 -> {
                holder!!.setText(R.id.tv_read_status, "未读")
                holder!!.setTextColor(R.id.tv_read_status,context!!.resources.getColor(R.color.gallery_red))
            }
            1 -> {
                holder!!.setText(R.id.tv_read_status, "已读")
                holder!!.setTextColor(R.id.tv_read_status,context!!.resources.getColor(R.color.gallery_green))
            }

            else -> {
            }
        }
    }
}